#include "fxcc/core/audio/openal/World.h"

using namespace fxcc::audio::openal;

World::World()
{
}

void World::Destroy()
{
    alcMakeContextCurrent(NULL);
    alcDestroyContext(m_Context);
    alcCloseDevice(m_Device);
}

bool World::Init()
{
    m_Device = alcOpenDevice(NULL);

    if (!m_Device) {
        return false;
    }

    m_Context = alcCreateContext(m_Device, NULL);
    alcMakeContextCurrent(m_Context);

    return m_Device;
}

bool fxcc::audio::openal::World::TryInit()
{
    if (m_HasLoad)
    {

    }
    else
    {
        Init();
        m_HasLoad = true;
    }
    return true;
}

World::~World()
{
    Destroy();
}

World& World::Inst()
{
    static World res;
    return res;
}


